package com.sy2.netshop.service;

import com.sy2.netshop.core.Result;
import com.sy2.netshop.entity.Commodity;
import com.sy2.netshop.mapper.ComMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ComService {
    @Autowired
    public ComMapper comMapper;

    public Result searchCommodity(String pname, Integer m){
        List<Commodity> cList = comMapper.getComByPname(pname,m);
        Result result = new Result();
        if(cList==null){
            result.setCode(400);
            result.setMsg("商品不存在");
        }else{
            result.setCode(200);
            result.setMsg("查找成功");
            result.setData(cList);
        }
        return  result;
    }
}
